package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportVisitsLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2022-09-16 18:56:07
 */
@Repository
public class TransportVisitsLogDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportVisitsLogDao.class);

    public TransportVisitsLog insert(final TransportVisitsLog transportVisitsLog) {
        insert("TransportVisitsLog.insert", transportVisitsLog);
        return transportVisitsLog;
    }

    public Boolean updateInfoById(final TransportVisitsLog transportVisitsLog) {
        return update("TransportVisitsLog.updateInfoById", transportVisitsLog) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportVisitsLog.updateInfoByQuery", query) > 0;
    }

    public TransportVisitsLog selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportVisitsLog.selectById", query);
    }

    public List<TransportVisitsLog> selectByQuery(final Query query) {
        return queryForList("TransportVisitsLog.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportVisitsLog.countByQuery", query);
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportVisitsLog.deleteById", query) > 0;
    }

    //获取总访问数
    public Long getTotalVisits(final Query query) {
        return queryForObject("TransportVisitsLog.getTotalVisits", query);
    }

}